package com.example.testwebview;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends Activity {

	WebView webView;
	EditText url;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		webView = (WebView) findViewById(R.id.webview);
		webView.setWebViewClient(new MyWebViewClient());
		webView.getSettings().setJavaScriptEnabled(true);
		
		url = (EditText) findViewById(R.id.url);
		
		Button go = (Button) findViewById(R.id.go);
		go.setOnClickListener(sendListener);
	}
	
	private OnClickListener sendListener = new OnClickListener() {
		
		public void onClick(View v) {	
			webView.loadUrl(url.getText().toString());
			webView.requestFocus();
		}
	};
	
	private class MyWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
        
        
  }

}
